using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace Moogle
{
    /// <summary>
    /// Classed to represent a specific
    /// point in time when a medication
    /// should be taken.
    /// </summary>
    public class PopTime
    {
        /// <summary>
        /// Integer value used to store the 
        /// sequential (or database assigned)
        /// id of the medication.
        /// </summary>
        public Int32 PopTimeID
        {
            get;
            set;
        }
        /// <summary>
        /// String defining the name of the medication.
        /// </summary>
        public String MedicationName
        {
            get;
            set;
        }
        /// <summary>
        /// Integer value defining the Hour.
        /// </summary>
        public Int32 Hour
        {
            get;
            set;
        }
        /// <summary>
        /// Integer value defining the Minute.
        /// </summary>
        public Int32 Minute
        {
            get;
            set;
        }
        /// <summary>
        /// Boolean value indicating whether the
        /// time is before noon.
        /// </summary>
        public Boolean AnteMeridiem
        {
            get;
            set;
        }
        /// <summary>
        /// Boolean value indicating whether the
        /// time is after noon.
        /// </summary>
        public Boolean PostMeridiem
        {
            get;
            set;
        }
        /// <summary>
        /// Class value function that can be used
        /// to reformat the time attributes of the
        /// class into a ##:## @@ format -- for example, "01:00 AM".
        /// </summary>
        /// <param name="pHour">Int32 value defining the hour</param>
        /// <param name="pMin">Int32 value defining the minutes</param>
        /// <param name="pAnteMeridiem">Boolean value indicating whether before noon</param>
        /// <returns>string value containing the properly formatted timestamp--ie ##:## @@ format.</returns>
        public static string TimeStamp(Int32 pHour, Int32 pMin, Boolean pAnteMeridiem)
        {
            string _strResult = string.Empty;
            try
            {
                String _strHour = pHour.ToString();
                String _strMin = pMin.ToString();
                String _strAmPm = string.Empty;
                String _strTimeStamp = string.Empty;

                if (pAnteMeridiem == true)
                    _strAmPm = " AM";
                else
                    _strAmPm = " PM";

                if (_strHour.Length == 1)
                    _strHour = "0" + _strHour;
                if (_strMin.Length == 1)
                    _strMin = "0" + _strMin;

                _strResult = _strHour + ":" + _strMin + _strAmPm;
            } // try
            catch (SystemException err)
            {
                throw err;
            } // catch
            return _strResult;
        }
    }
}